import TIM from './TIM';

function initTim () {
  return new TIM({
    SDKAppID: 1600065623,
    SDKSecretKey: 'ae8a4768b98aa75a0c4ef11581b0f99fa2e5ee90092c646629f9fcf6030d437c',
    onReadyChange: (bool) => {
      console.log('isReady =======>', bool)
      this.$store.commit('UPDATE_READY', bool)
      if (bool) {
        this.$chat.$timInstance.updateMyProfile({
          nick: this.userInfo.nickName || this.userInfo.realName || '',
          avatar: this.userInfo.avatar
        }).then(res => {
          console.warn('更新资料成功 ===>', res) // 更新资料成功的相关信息
        }).catch(function(error) {
          console.warn('更新资料失败 ===>', error) // 更新资料失败的相关信息
        })
      }
    },
    onError: (error) => {
      console.log('error =======>', error)
    },
    onWarning: (res) => {
      uni.showToast({
        icon: 'none',
        title: res.message,
        duration: 3000,
      })
    }
  });
}
export default initTim;
